﻿using System;
using System.Collections.Generic;
using Gp.Scripts.Data;
using Gp.Scripts.Core;
using UnityEngine;

namespace Gp.Scripts.Equip {
    [Serializable]
    public class PileArmorEntity : IArmorProvider {
        public List<ArmorFragmentEntity> fragmentList;
        public ArmorEquip Equip { get; }

        public IEnumerable<ArmorFragmentEntity> ArmorFragments => fragmentList;

        public PileArmorEntity(ArmorEquip equip, BaseUnit unit) {
            Equip = equip;
            fragmentList = new List<ArmorFragmentEntity>();

            for (int i = 0; i < equip.divisions; i++) {
                fragmentList.Add(new ArmorFragmentEntity(this,
                    () => 30,
                    1));
            }
        }
        
        
        public static int CalTotalPileArmorPoint(float tenacityPoint) {
            return Mathf.RoundToInt(Math.Max(1, tenacityPoint * 20));
        }
    }
}